import MarkdownIt from 'markdown-it'

export default defineEventHandler(async (event) => {
  const body = await readBody(event)
  const md = new MarkdownIt()
  // 兼容 body 为字符串或对象
  const markdown = typeof body === 'string' ? body : body?.markdown || body?.md || ''
  const html = md.render(markdown)
  return { html }
})